import {
    apiBase
} from './common';
export function recommendNews(faiSessionKey) {
    return new Promise((resolve, reject) => {
        wx.request({
            url: `${apiBase}news/recommendations`,
            data: {
                faiSessionKey: faiSessionKey,
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
            },
            dataType: 'json',
            method: 'GET',
            success: (data, statusCode, header) => {
                resolve(data.data);
            },
            fail: () => {
                console.log(arguments);
                reject(arguments);
            }
        });
    });
}
export function removeNews(faiSessionKey, removedNewsId, existingNewsIdList = [], removedFromLabelId) {
    return new Promise((resolve, reject) => {
        wx.request({
            url: `${apiBase}news/${removedNewsId}/remove`,
            data: {
                faiSessionKey: faiSessionKey,
                existingNewsIdList: existingNewsIdList,
                removedFromLabelId: removedFromLabelId
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
            },
            dataType: 'json',
            method: 'POST',
            success: (data, statusCode, header) => {
                resolve(data.data);
            },
            fail: () => {
                console.log(arguments);
                reject(arguments);
            }
        });
    });
}

export function clickNews(faiSessionKey, clickedNewsId) {
    return new Promise((resolve, reject) => {
        wx.request({
            url: `${apiBase}news/${clickedNewsId}/click`,
            data: {
                faiSessionKey: faiSessionKey
            },
            header: {
                'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
            },
            dataType: 'json',
            method: 'POST',
            success: (data, statusCode, header) => {
                resolve(data.data);
            },
            fail: () => {
                console.log(arguments);
                reject(arguments);
            }
        });
    });
}